//
//  pushVC.m
//  EquiriesProject
//
//  Created by qianfeng on 15/10/31.
//  Copyright (c) 2015年 HXH. All rights reserved.
//

#import "pushVC.h"
#import "PushOneCell.h"
#import "PushTwoCell.h"

@interface pushVC ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation pushVC
{
    UITableView * _tableView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1];
    
    [self createNav];
    [self createTableView];
}

-(void)createTableView
{
    _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, 150) style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.scrollEnabled = NO;
    [self.view addSubview:_tableView];
    
    [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(0);
        make.right.equalTo(self.view.mas_right).offset(0);
        make.top.equalTo(self.MessageLabel.mas_bottom).offset(1);
        make.height.equalTo(@195);
    }];
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 1) {
        return 20;
    }
    return 0;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    NSArray * array = @[@"违章提醒",@"文章推送"];
    NSArray * array1 = @[@"限行推送",@"时间设置"];
    
    PushOneCell * oneCell = [_tableView dequeueReusableCellWithIdentifier:@"oneCell"];
    PushTwoCell * twoCell = [_tableView dequeueReusableCellWithIdentifier:@"twoCell"];
    if (!oneCell) {
//        oneCell = [[[NSBundle mainBundle]loadNibNamed:@"PushOneCell" owner:nil options:nil]lastObject];
        oneCell = [[[NSBundle mainBundle]loadNibNamed:@"PushOneCell" owner:nil options:nil]lastObject];
    }
    if (!twoCell) {
        twoCell = [[[NSBundle mainBundle]loadNibNamed:@"PushTwoCell" owner:nil options:nil]lastObject];
    }
    if (indexPath.section == 0) {
        oneCell.titleLabel.text = array[indexPath.row];
        return oneCell;
    }else{
        if (indexPath.row == 0) {
            oneCell.titleLabel.text = array1[indexPath.row];
            return oneCell;
        }
        twoCell.titleLabel.text = array1[indexPath.row];
        return twoCell;
    }
}

-(void)createNav
{
    UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 120, 40)];
    label.text = @"提示设置";
    label.textAlignment = NSTextAlignmentCenter;
    label.textColor = [UIColor whiteColor];
    label.font = [UIFont systemFontOfSize:22];
    [self.view addSubview:label];
    self.navigationItem.titleView = label;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
